export default {
  data() {
    return {
      goods: {
        shopName: '',
        shopNumber: '',
        shopSpec: '',
        shopPrice: '',
        shopAmount: ''
      },
      spec:[{
        label:'斤',
        value:'斤'
      },
      {
        label:'件',
        value:'件'
      },{
        label:'袋',
        value:'袋'
      },
      {
        label:'箱',
        value:'箱'
      },
      {
        label:'盒',
        value:'盒'
      },
      {
        label:'瓶',
        value:'瓶'
      },
      {
        label:'条',
        value:'条'
      },
      {
        label:'包',
        value:'包'
      },
      {
        label:'个',
        value:'个'
      },
      
    ],
      shopTitle:'',
      openShop:false
    }
  },
  computed:{
    
  },
  methods:{
    resetShopForm(){
      this.goods = {
        shopName: '',
        shopNumber: '',
        shopSpec: '',
        shopPrice: '',
        shopAmount: ''
      }
    },
    handleAddOneGoods(){
        this.resetShopForm()
      this.shopTitle = '新增商品'
      this.openShop = true
    },
    handleInputChange(){
      this.goods.shopAmount =(this.goods.shopPrice * this.goods.shopNumber).toFixed(2)
    },
    submitShopForm(){
      this.$refs.form.validate((valid) => {
        if (valid) {
        //   this.$emit('submitShopForm', this.goods)
        // this.form.detail.push(this.goods)
        this.$nextTick(() => {
          this.$set(this.form.detail, this.form.detail.length, this.goods)
          this.cancelShop()
          console.log('this.form.detail==>',this.form.detail)
        })
        }
      })
    },
    cancelShop(){
      this.resetShopForm()
      this.openShop = false
    },
    handleShopIdChange(){
        this.$set(this.goods, 'shopName', this.shopList.find(item => item.id === this.goods.shopId).shopName)
        console.log('this.goods==>',this.goods)
    }
  }
}